/*     */ package com.zimbra.cs.service.admin;
/*     */ 
/*     */ import com.zimbra.common.account.Key.CosBy;
/*     */ import com.zimbra.common.account.Key.DomainBy;
/*     */ import com.zimbra.common.service.ServiceException;
/*     */ import com.zimbra.common.soap.AdminConstants;
/*     */ import com.zimbra.common.soap.Element;
/*     */ import com.zimbra.common.util.Log;
/*     */ import com.zimbra.common.util.ZimbraLog;
/*     */ import com.zimbra.cs.account.AccountServiceException;
/*     */ import com.zimbra.cs.account.Cos;
/*     */ import com.zimbra.cs.account.Domain;
/*     */ import com.zimbra.cs.account.Provisioning;
/*     */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*     */ import com.zimbra.cs.account.accesscontrol.Rights.Admin;
/*     */ import com.zimbra.soap.ZimbraSoapContext;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class ModifyDomain
/*     */   extends AdminDocumentHandler
/*     */ {
/*     */   public boolean domainAuthSufficient(Map context)
/*     */   {
/*  45 */     return true;
/*     */   }
/*     */   
/*     */   public Element handle(Element request, Map<String, Object> context) throws ServiceException
/*     */   {
/*  50 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/*  51 */     Provisioning prov = Provisioning.getInstance();
/*     */     
/*  53 */     String id = request.getAttribute("id");
/*  54 */     Map<String, Object> attrs = AdminService.getAttrs(request);
/*     */     
/*  56 */     Domain domain = prov.get(Key.DomainBy.id, id);
/*  57 */     if (domain == null) {
/*  58 */       throw AccountServiceException.NO_SUCH_DOMAIN(id);
/*     */     }
/*  60 */     if (domain.isShutdown()) {
/*  61 */       throw ServiceException.PERM_DENIED("can not access domain, domain is in " + domain.getDomainStatusAsString() + " status");
/*     */     }
/*  63 */     checkDomainRight(zsc, domain, attrs);
/*     */     
/*     */ 
/*  66 */     checkCos(zsc, attrs, "zimbraDomainDefaultCOSId");
/*  67 */     checkCos(zsc, attrs, "zimbraDomainDefaultExternalUserCOSId");
/*     */     
/*     */ 
/*  70 */     prov.modifyAttrs(domain, attrs, true);
/*     */     
/*  72 */     ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "ModifyDomain", "name", domain.getName() }, attrs));
/*     */     
/*     */ 
/*  75 */     Element response = zsc.createElement(AdminConstants.MODIFY_DOMAIN_RESPONSE);
/*  76 */     GetDomain.encodeDomain(response, domain);
/*  77 */     return response;
/*     */   }
/*     */   
/*     */   private void checkCos(ZimbraSoapContext zsc, Map<String, Object> attrs, String defaultCOSIdAttrName) throws ServiceException
/*     */   {
/*  82 */     String newDomainCosId = ModifyAccount.getStringAttrNewValue(defaultCOSIdAttrName, attrs);
/*  83 */     if (newDomainCosId == null) {
/*  84 */       return;
/*     */     }
/*  86 */     Provisioning prov = Provisioning.getInstance();
/*  87 */     if (newDomainCosId.equals(""))
/*     */     {
/*  89 */       return;
/*     */     }
/*     */     
/*  92 */     Cos cos = prov.get(Key.CosBy.id, newDomainCosId);
/*  93 */     if (cos == null) {
/*  94 */       throw AccountServiceException.NO_SUCH_COS(newDomainCosId);
/*     */     }
/*     */     
/*     */ 
/*     */ 
/*     */ 
/* 100 */     checkRight(zsc, cos, Rights.Admin.R_assignCos);
/*     */   }
/*     */   
/*     */   public void docRights(List<AdminRight> relatedRights, List<String> notes)
/*     */   {
/* 105 */     notes.add(String.format("All attrs provided in the attribute list have to settable by. the authed admin.   You can grant the %s right, which allows setting all attributes on %s, or grant the set attrs right just for the attributes the admin needs to set while creating an entry.", new Object[] { Rights.Admin.R_modifyDomain.getName(), "domain" }));
/*     */     
/*     */ 
/* 108 */     notes.add("Notes on zimbraDomainDefaultCOSId: If setting zimbraDomainDefaultCOSId, needs the " + Rights.Admin.R_assignCos.getName() + " right on the cos.");
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/ModifyDomain.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */